// 引入网络请求
import service from './request.js'
const firstApi = {
  get(url, args = {}) {
    return service.get(url, args);
  },
  put(url, args = {}) {
    return service.put(url, args);
  },
  delete(url, args = {}) {
    return service.delete(url, args);
  },
  post(url, args = {}, mm) {
    return service.post(url, args, mm);
  },
  doLogin(data) {
    //登录
    return this.post(process.env.BASE_API + 'api/login/', data,);
  },
  LoginGetDept(data) {
    //登录时获取部门id
    return this.get(process.env.BASE_API + `api/system/dept_user/${data.id}`);
  },
  yanzhengma(data) {
    return this.get(process.env.BASE_API + 'api/captcha/', data,);
  },
  greenhouseList(data, id) {
    //左侧列表名称
    return this.get(process.env.BASE_API + `shake/device_list`);
    // return this.get(process.env.BASE_API + `shake/device_list/${data}/${id}`);
  },
  //配电柜名称
  cabinets(data) {
    return this.get(process.env.BASE_API + 'iot/cabinets/', { params: data });
  },
  points(data) {
    // return this.get(process.env.BASE_API + 'iot/cabinet/points/', { params: data });
    return this.get(process.env.BASE_API + 'api/cabinet/newpoints/', { params: data });
  },
  pointslist(data) {
    return this.get(process.env.BASE_API + 'iot/points/list/', { params: data });
  },
  pointdetail(data) {
    return this.get(process.env.BASE_API + 'iot/point/detail/', { params: data });
  },
  pointdetail2(data) {
    return this.get(process.env.BASE_API + 'iot/warn/point/line/', { params: data });
  },
  warnslist(data) {
    return this.get(process.env.BASE_API + 'iot/warns/list/', { params: data });
  },
  online(data) {
    return this.get(process.env.BASE_API + 'iot/online/count/', { params: data });
  },
  warncount(data) {
    return this.get(process.env.BASE_API + 'iot/warn/count/', { params: data });
  },
  early_warn(data) {
    return this.get(process.env.BASE_API + 'iot/warn/early_warn/count/', { params: data });
  },
  cabinetsort(data) {
    return this.get(process.env.BASE_API + 'iot/warn/cabinet/sort/', { params: data });
  },
  pointsort(data) {
    return this.get(process.env.BASE_API + 'iot/warn/point/sort/', { params: data });
  },
  rooms(data) {
    //能耗趋势图
    return this.get(process.env.BASE_API + 'iot/rooms/', { params: data });
  },
  // //能耗监控页面
  roomdetails(data) {
    return this.get(process.env.BASE_API + 'iot/room/details/', { params: data });
  },

//空气温湿度界面数据
  tah(data){
    return this.get(process.env.BASE_API +"api/room/details/",{ params: data });
  },


  cabinetdetails(data) {
    return this.get(process.env.BASE_API + 'iot/cabinet/details/', { params: data });
  },
  cabinetabc(data) {
    return this.get(process.env.BASE_API + 'iot/cabinet/ABC/', { params: data });
  },
  gradations(data) {
    return this.get(process.env.BASE_API + 'iot/cabinet/gradations/', { params: data });
  },
  compare(data) {
    return this.get(process.env.BASE_API + 'iot/cabinet/ABC/compare/', { params: data });
  },
  // warnline(data) {
  //   return this.get(process.env.BASE_API + 'iot/warn/history/line/', { params: data });
  // },
  warnline(data) {
    return this.get(process.env.BASE_API + 'api/warn/history/newline/', { params: data });
  },

  // warntable(data) {
  //   return this.get(process.env.BASE_API + 'iot/warn/history/table/', { params: data });
  // },
  warntable(data) {
    return this.get(process.env.BASE_API + 'api/warn/history/newtable/', { params: data });
  },
  voltagedetail(data) {
    return this.get(process.env.BASE_API + 'iot/voltage/detail/', { params: data });
  },
  is_handel(data) {
    return this.get(process.env.BASE_API + 'iot/temp/is_handel/', { params: data });
  },
  warning(data) {
    return this.get(process.env.BASE_API + 'iot/warn/warning/', { params: data });
  },
  setuser(data) {
    return this.get(process.env.BASE_API + 'api/system/user/', { params: data });
  },
  adduser(data) {
    return this.post(process.env.BASE_API + 'iot/create/user/ ', data);
  },
  edituser(data) {
    return this.post(process.env.BASE_API + 'iot/update/user/ ', data);
  },

  deluser(data) {
    return this.delete(process.env.BASE_API + `api/system/user/${data.pk}/`);
  },

  editpass(data) {
    return this.put(process.env.BASE_API + `api/system/user/${data.id}/reset_password/`, data);
  },

  setdept(data) {
    return this.get(process.env.BASE_API + 'api/system/dept/', { params: data });
  },


  setcabinet(data) {
    return this.get(process.env.BASE_API + 'api/iot/cabinet/', { params: data });
  },
  editsetcabinet(data) {
    return this.put(process.env.BASE_API + `api/iot/cabinet/${data.id}/`, data);
  },
  // shebeixuanze
  setsectlt(data) {
    return this.get(process.env.BASE_API + 'iot/rooms/', { params: data });
  },
  daochuzheli(data) {
    return service({
      url: process.env.BASE_API + `iot/download/`,
      methods: 'get',
      params: data,
      responseType: 'arraybuffer',
    })
    // this.get(process.env.BASE_API + `iot/download/`, {params:data},
    // // {responseType: 'blob'},
    // {responseType : 'arraybuffer' },
    // {headers: {'Content-Type': 'multipart/form-data'}});
  },
  // 时间维度
  timeDimension(data){
    return this.get(process.env.BASE_API+'iot/ele/time/type/', { params: data });
  },
  // 实时数据
  realTime(data){
    return this.get(process.env.BASE_API+'iot/ele/device/list/', { params: data })
  },
  // 实时数据 本日趋势
  realTimeTrend(data){
    return this.get(process.env.BASE_API+'iot/ele/device/day/detail/', { params: data })
  },
  // 抄表数据 表格
  meterData(data){
    return this.get(process.env.BASE_API+'iot/ele/device/time/type/detail/', { params: data })
  },
  daochuhuanjing(data){
    return this.get(process.env.BASE_API+'iot/air/', { params: data })
  }

}
export default firstApi
